package com.wj.opratorlog.utils;

import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import java.text.SimpleDateFormat;
import java.time.Year;
import java.util.Date;

public class YearMonth {

    private long year;

    private long month;



    public long getYear() {
        return year;
    }

    public void setYear(long year) {
        this.year = year;
    }

    public long getMonth() {
        return month;
    }

    public void setMonth(long month) {
        this.month = month;
    }

    public     YearMonth(){


    }

    public YearMonth(long year, long month) {
        this.year = year;
        this.month = month;

    }

    public  YearMonth getCurrentDate(){

        long l = System.currentTimeMillis();
        Date date = new Date(l);
        YearMonth yearMonth = new YearMonth();
          yearMonth.setMonth(date.getMonth());
          yearMonth.setYear(date.getYear());
          return yearMonth;
    }

    // yyyy/mm

    //  2007/7
     public  String getYearMonthFormatering( YearMonth  yearMonth, String  pattern){

      return   yearMonth.getYear()+"/"+ yearMonth.getMonth();

      }

      public   YearMonth   yearMonthAdd( YearMonth  yearMonth , int  addMonth){
         this.setMonth(yearMonth.getMonth()+addMonth);
          return  yearMonth;
      }

    public   YearMonth   yearMonthAdd( long curentYear ,long curentMonth, int  addMonth) {

        Assert.hasText(String.valueOf(curentYear), "年份不能为空");

        Assert.hasText(String.valueOf(curentMonth), "月份不能为空");

        if (String.valueOf(curentYear).length() != 4) {

        }

        return null;

    }

 }
